package workers

import (
	"gitee.com/captials-team/ubdframe/src/domain/dto/cmddata"
	"gitee.com/captials-team/ubdframe/src/pkg/logs"
	"gitee.com/captials-team/ubdframe/src/pkg/wsserver"
)

type DemoWorker struct {
}

func (w *DemoWorker) Name() string {
	return "demo"
}

func (w *DemoWorker) Receive(cmd *cmddata.ClientCmd) {
	logs.Out.Info("RECEIVE %+v", cmd)

	cmd.Client.SendMessage(&cmddata.ClientAnswer{
		Group:   cmd.FirstAction(),
		Message: "receive success",
	})
}

func (w *DemoWorker) Online(client *wsserver.Client) {
	logs.Out.Info("ONLINE %s", client.ID())

	client.SendMessage(&cmddata.ClientAnswer{
		Group:   w.Name(),
		Message: "this is demo",
	})
}

func (w *DemoWorker) Close(client *wsserver.Client) {
	logs.Out.Info("CLOSED %s", client.ID())
	return
}

func (w *DemoWorker) NeedAccredit(client *wsserver.Client) bool {
	return false
}
